﻿using System;
using System.Runtime.Serialization;
using EasyComm.Logging;
using EasyComm.Workstation.Info;

namespace EasyComm.Workstation
{
    [Serializable]
    public class Process : ISystemObject
    {
        public event LogEventHandler Log;

        public int ID { get; private set; }
        public Computer Machine { get; set; }
        public string CommandLine { get; set; }

        public int MaxThreads { get; set; }
        public int MaxMemoryAllocation { get; set; }
        public int MaxCPUAllocationPercent { get; set; }

        [NonSerialized]
        private CPU _processor;
        public CPU Processor
        {
            get
            {
                return _processor;
            }
            private set
            {
                _processor = value;
            }
        }

        public Process()
        {

        }

        public void Run()
        {

        }

        public void OnLog(string message, MessageType messageType)
        {
            if (Log != null)
            {
                Log(this, new LogEventArgs(messageType, message));
            }
        }

        [OnDeserialized]
        private void SetValuesOnDeserialized(StreamingContext context)
        {
            // Code not shown.
        }
    }
}
